|
Contents |
|
Edgar Model has the following convention so when using edgar_scaffold, naming of columns should comply that.
'Name' column or method is required when the model is used at popup-selection.
The model, which is generated by edgar_scaffold, is *NOT* required to have 'name' column or method. However, when it is referred by other model as 'belongs_to', it is required to have 'name' since Edgar popup-selection uses it. So, it is recommended to have 'name' column or method at design phase of the model.
(NOTE: Address feature is still under construction. Document in this section is just current way.)
In order to add address in a model, declare by edgar_address as follows:
class Author < ActiveRecord::Base : edgar_address :adrs : end
Edgar::FieldHelper.draw_adrs() helper displays address.
Address partial template app/views/edgar/_address.html.erb can be customized also if you don't like that ;-(...
Currently, edgar_address requires following manual logic to initialize address column (see test/dummy/app/models/author.rb as an example):
class Author < ActiveRecord::Base ... def initialize(attrs = {}) super self.adrs = Edgar::Address.new if self.adrs == nil end end
'Enum' in Edgar is a module which integer constants are defined. draw_enum() draws selection for an integer AR column.
Selection-option label is I18n supported by AR human_const_name API.
Following Question module's Priority selection on @question.priority integer column:
<% edgar_form_for do |f| %> : <%= draw_enum(f, :priority) %> : <% end %>
shows:
config.default/locales/*.yml activerecord.enums.question/priority entry shows how selection-option label is I18n-ed.
When an integer column 'xyz' is defined and there is 'XyzBitset' module which contains 2^n^ constants (e.g. bitflag 0x01, 0x02, 0x04, ...), Edgar::FieldHelper.draw_bitset() helper draws checkboxes for each bitflag.
Each constant can be I18n.
ModelPermission model is the actual example:
class Edgar::ModelPermission < ActiveRecord::Base : module FlagsBitset CREATE = 0x01 READ = 0x02 UPDATE = 0x04 DELETE = 0x08 end : end
Following example:
<%= draw_flags(f, :flags) %> :
shows:
Where, f is FormBuilder variable.
There is no file upload support at Edgar level, but Paperclip + Remotipart work great! Please see Book model test/dummy/app/models/book.rb and Book view test/dummy/app/views/books/ how to use them.